package com.rui.patterns.command;

import java.util.Map;
import java.util.Set;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : OrderCommand
 * @createTime : [2022/2/23 18:02]
 * @description : [描述该类的功能]
 */

public class OrderCommand implements Command {

    private SeniorChef receiver;

    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌的订单: ");
        Map<String, Integer> foodDir = order.getFoodDir();

        //遍历map集合
        Set<String> keys = foodDir.keySet();
        for(String foodName : keys){
            receiver.makeFood(foodName, foodDir.get(foodName));
        }
        System.out.println(order.getDiningTable() + "桌的订单已经完成");
    }
}
